<?php

namespace App\Http\Requests\Admin;

use App\Models\Admin;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class AdminUpdateRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
		return [
			'password' => 'bail|sometimes|nullable|string|max:16',
			'nickname' => [
				'bail',
				'required',
				Rule::unique('admin')->ignore(request()->input('id')),
				'string',
				'max:20'
			],
			'age'      => 'bail|sometimes|integer|max:121',
			'sex'      =>
				[
					'integer',
					Rule::in(['1', '0'])
				],
			'status'   =>
				[
					'integer',
					Rule::in(['1', '0'])
				],
		];
    }

	public function attributes()
	{
		return [
			'username'=>'用户名',
			'password'=>'密码',
			'nickname'=>'昵称',
			'age'=>'年龄',
			'sex'=>'性别',
			'status'=>'用户状态',

		];
	}
}
